package hai.wom.org.qyer_destination.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.squareup.picasso.Picasso;

import java.util.List;

import hai.wom.org.qyer_destination.R;
import hai.wom.org.qyer_destination.bean.HotCity;
import hai.wom.org.qyer_destination.fragment.Fragment_Hot;

/**
 * Created by Administrator on 2017/1/12 0012.
 */

public class MyAdapter_City extends BaseAdapter {
//    private List<HotCity.DataEntity> list;
    private List<HotCity.DataEntity.DestinationsEntity> list;
    private Context context;

    public MyAdapter_City(Context context, List<HotCity.DataEntity.DestinationsEntity> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.item_city_fg, parent, false);
            holder = new ViewHolder();
            holder.iv = (ImageView) convertView.findViewById(R.id.iv_item_city);
            holder.tv1 = (TextView) convertView.findViewById(R.id.tv_name_item_city);
            holder.tv2 = (TextView) convertView.findViewById(R.id.tv_englishName_item_city);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.tv1.setText(list.get(position).getName());
        holder.tv2.setText(list.get(position).getName_en());
        Picasso.with(context).load(list.get(position).getPic()).into(holder.iv);
        return convertView;
    }

    class ViewHolder {
        ImageView iv;
        TextView tv1, tv2;
    }

}
